package com.neusoft.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
	private ServerSocket ss =null ;
	private Socket s =null;
	private BufferedReader bf = null;
	private PrintWriter pw =null;
	public Server(){
		try {
			ss = new ServerSocket(8888);
			while(true){
				s = ss.accept();
				bf = new BufferedReader(new InputStreamReader(s.getInputStream()));
				String line = bf.readLine();
				System.out.println(line);
				pw = new PrintWriter(s.getOutputStream(),true);
				pw.println("Your Message Received!");
				pw.close();
				bf.close();
				s.close();
			}
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		
	}
	public static void main(String[] args) {
		new Server();
	}
}
